package com.rockcent.service.impl;

import com.rockcent.common.common.PageResult;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.IntegrationChannel;
import com.rockcent.mall.lib.dto.IntegrationChannelDto;
import com.rockcent.mall.lib.repository.IntegrationChannelRepository;
import com.rockcent.service.IntegrationChannelSrv;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by zhangjh on 2016/12/27.
 */
@Service
public class IntegrationChannelSrvImpl implements IntegrationChannelSrv {

    @Autowired
    private IntegrationChannelRepository integrationChannelRepository;

    @Override
    public PageResult<IntegrationChannelDto> findByNameAndMallIdAndIsDelete(String name, Long mallId, Whether no, PageResult page) {
        return integrationChannelRepository.findByNameAndMallIdAndIsDelete(name, mallId, no, page);
    }

    @Override
    public IntegrationChannel findByAppKey(String appKey) {
        return integrationChannelRepository.findByAppKeyAndIsDelete(appKey, Whether.NO);
    }

    @Override
    public IntegrationChannel findOne(Long id) {
        return integrationChannelRepository.findByIdAndIsDelete(id, Whether.NO);
    }

    @Override
    public Long caculateQuantityByChannelId(Long integrationChannelId, Long mallId) {
        return integrationChannelRepository.caculateQuantityByChannelId(integrationChannelId, mallId);
    }
}
